package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface FriendDao extends JpaRepository<Friend, String> {

    // 查询喜欢
    @Query(value = "SELECT * FROM tb_friend WHERE userid=? AND friendid=?", nativeQuery = true)
    public Friend findByUseridAndFriendid(String userid, String friendid);

    // 更新喜欢
    @Modifying
    @Query(value = "UPDATE tb_friend set islike=? WHERE userid=? AND friendid=?", nativeQuery = true)
    public void updateIsLike(String isLike, String userId, String friend);

    /**
     * 删除好友
     */
    @Modifying
    @Query(value = "DELETE FROM tb_friend WHERE userid=? AND friendid=?", nativeQuery = true)
    public void deletefriend(String userId, String friendId);
}
